public class Read { public static String getString(String msg) { boolean success = false; String r = ""; while (!success) try { System.out.print(msg); r = System.console().readLine(); success = true; } catch (Exception e) { } return r; } public static String getString() { return getString(""); } public static int getInt(String msg) { boolean success = false; int r = 0; while (!success) try { System.out.print(msg); r = Integer.parseInt( System.console().readLine() ); success = true; } catch (Exception e) { } return r; } public static int getInt() { return getInt(""); } public static double getDouble(String msg) { boolean success = false; double r = 0; while (!success) try { System.out.print(msg); r = Double.parseDouble( System.console().readLine() ); success = true; } catch (Exception e) { } return r; } public static double getDouble() { return getDouble(""); } public static float getFloat(String msg) { boolean success = false; float r = 0; while (!success) try { System.out.print(msg); r = Float.parseFloat( System.console().readLine() ); success = true; } catch (Exception e) { } return r; } public static float getFloat() { return getFloat(""); } }